home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group02b.txt / 000167_icon-group-sender_Tue Dec 24 12:31:58 2002.msg < prev    next >
Internet Message Format  |  2003-01-02  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id gBOJVv206539
  4.     for icon-group-addresses; Tue, 24 Dec 2002 12:31:57 -0700 (MST)
  5. Message-Id: <200212241931.gBOJVv206539@baskerville.CS.Arizona.EDU>
  6. From: ernobe <ernobe@msn.com>
  7. X-Newsgroups: comp.lang.icon
  8. Subject: Re: Scanning question
  9. Date: Tue, 24 Dec 2002 07:12:01 +0200
  10. X-Newsreader: MicroPlanet Gravity v2.50
  11. To: icon-group@cs.arizona.edu
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13. Status: RO
  14.  
  15. In article <au88ah$5chfl$1@ID-79573.news.dfncis.de>, ahamm@mail.com says...
  16. > ernobe wrote:
  17. > > Can a scanning operation be done within a conjunction?  It seems that
  18. > > backtracking into it does not produce the next result but begins the
  19. > > scanning over again.  And if the '?' scanning expression is put out
  20. > > of the conjunction, the part that is left in it sets the position
  21. > > back to where it was before scanning when the other expressions in
  22. > > the conjunction are evaluated.
  23. > A sample of code please? Conjunction does backtrack so probably you are
  24. > doing something to break the scan.
  25. I wanted to scan thru several lines in a file searching for strings that have 
  26. been scanned out of another file.  So if an operation on a specific line fails 
  27. to produce results, I need to go to the next line while keeping count of the 
  28. number of strings that have been scanned ( I need to match the string itself 
  29. and find its position in the file ).  I had something like
  30.  
  31. var := 1 # number of string
  32. every 
  33. line := read() do (
  34. line ? while tab( upto( &letters ) ) do 
  35. str := tab( many( &letters ) ) \ 1,
  36. count +:= 1,
  37. if count = var then write( file, str ),
  38. count := 0 )
  39.  
  40. The problem is that if a line has no matches, I need to continue with another 
  41. line without setting the count back to zero.  'Every' is not a loop structure 
  42. so I can't put a 'next' in there before the count is set back to zero.  I 
  43. realize now that the scanning expression itself was not the problem after all.  
  44. I need to re-organize my program.  By the way, if the 'then' clause fails in 
  45. the conjunction, does the 'if' clause itself fail?  If one backtracks into a 
  46. conjunction, does the whole thing resume, or just the final expression?
  47.  
  48.  
  49.  
  50.  
  51. -- 
  52. my esoteric links:
  53. http://www.costarricense.cr/pagina/ernobe/
  54.